<template>
  <div class="zh-teaching-resources">
    <nav-header></nav-header>
    <div class="zh-table">
      <div class="zh-table-open clear">
        <div class="zh-open-left fl">
          <div class="open-width" style="width: 150px" v-if="$store.state.checkLevel">
            <el-select v-model="listParam.school_code" v-if="$store.state.platformInformation" filterable
              placeholder="教育局/学校">
              <el-option v-for="item in schoolcodeData" :key="item.id" :label="item.name" :value="item.app_code">
              </el-option>
            </el-select>
            <el-cascader placeholder="组织架构选择" v-else v-model="valueData" :options="allList" :props="optionProps">
            </el-cascader>
          </div>
          <div style="display: inline-block;" v-else>
            <div class="open-width" style="width: 100px">
              <el-select v-model="listParam.study_section_id" filterable placeholder="请选择">
                <el-option v-for="item in orgLevel2" :key="item.id" :label="item.name" :value="item.id">
                </el-option>
              </el-select>
            </div>
            <div class="open-width" style="width: 100px">
              <el-select v-model="listParam.grade_id" filterable placeholder="请选择">
                <el-option v-for="item in orgLevel3" :key="item.id" :label="item.name" :value="item.id">
                </el-option>
              </el-select>
            </div>
            <div class="open-width" style="width: 100px">
              <el-select v-model="listParam.subject_id" filterable placeholder="请选择">
                <el-option v-for="item in orgSubject" :key="item.id" :label="item.name" :value="item.id">
                </el-option>
              </el-select>
            </div>
            <div class="open-width" style="width: 100px">
              <el-select v-model="listParam.version_id" filterable placeholder="请选择">
                <el-option v-for="item in orgVersion" :key="item.id" :label="item.name" :value="item.id">
                </el-option>
              </el-select>
            </div>
          </div>
          <div class="open-width" style="width: 120px" v-if="$store.state.checkLevel">
            <el-select v-model="cate_id" filterable placeholder="全部类型">
              <el-option v-for="item in resoureKindData" :key="item.id" :label="item.name" :value="item.id">
              </el-option>
            </el-select>
          </div>
          <div class="open-width" style="width: 120px">
            <el-select v-model="listParam.authonity" filterable placeholder="选择状态">
              <el-option label="全部状态" :value="-1"></el-option>
              <el-option label="私有" :value="0"></el-option>
              <el-option label="公开" :value="1"></el-option>
            </el-select>
          </div>
          <div class="open-width">
            <el-input v-model="listParam.keyword" placeholder="请输入资源名、用户名搜索" @keyup.enter.native="searchFunc">
            </el-input>
          </div>
          <el-button type="primary" @click="searchFunc">搜索</el-button>
          <el-button type="primary" @click="reset">重置</el-button>

        </div>
        <div class="zh-open-right fr">
          <el-button type="text" v-if="$store.state.checkLevel && app_code !== '00000000000000000000000000000000'"
            @click="toLink('/resources/resource/resource-push-history?per=教学资源&type=1')">推送历史</el-button>
          <el-button type="primary" v-show="!isTopEducation" v-if="$store.state.checkLevel" @click="pushUpAll">批量推上级
          </el-button>
          <el-button type="primary" @click="upload()">上传资源</el-button>
          <el-button type="danger" @click="delAllresource">批量删除</el-button>
        </div>
      </div>
      <div class="zh-table-contents" v-loading="loading.status" :element-loading-text="loading.txt">
        <el-table :data="listData" border max-height="600" @selection-change="handleSelectionChange" style="width: 100%">
          <el-table-column type="selection" align="center" show-overflow-tooltip width="50">
          </el-table-column>
          <el-table-column prop="name" label="资源名称" align="center" show-overflow-tooltip>
            <template slot-scope="scope">
              {{ scope.row.name }}.{{ scope.row.postfix }}
            </template>
          </el-table-column>
          <el-table-column label="审核状态" align="center" v-if="!$store.state.checkLevel" show-overflow-tooltip>
            <template slot-scope="scope">
              <div v-html="getStatus(scope.row.status)"></div>
            </template>
          </el-table-column>
          <el-table-column label="组织架构" align="center" show-overflow-tooltip prop="category">
          </el-table-column>
          <el-table-column label="分类" prop="cate_name" align="center" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="u_name" label="上传人" align="center" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="create_time" label="上传时间" align="center" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="status" label="状态" align="center" show-overflow-tooltip>
            <template slot-scope="scope">
              <div v-if="scope.row.authority === 1">公开</div>
              <div v-else>私有</div>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" width="275" show-overflow-tooltip>
            <template slot-scope="scope">
              <el-button @click="viewResource(scope.row)" type="text">预览</el-button>
              <template v-if="parseInt(scope.row.status) === 2">
                <el-button @click="approve_confirm(scope.row)" type="text">批准</el-button>
                <el-button @click="disapprove_dialog(scope.row)" type="text">拒绝</el-button>
              </template>
              <template v-if="parseInt(scope.row.status) === 1">
                <el-button @click="down(scope.row)" type="text">下载</el-button>
                <el-button v-show="scope.row.authority !== 0" @click="jumpEdit(scope.row.id)" type="text">编辑</el-button>
              </template>
              <template v-if="$store.state.checkLevel">
                <el-button v-show="scope.row.authority !== 0 && !isTopEducation" @click="pushUpTrigger(scope.row)"
                  type="text">推上级</el-button>
                <!-- <el-button v-if="!$store.state.platformInformation" @click="pushLow(scope.row)" type="text">推下级</el-button> -->
              </template>
              <template v-if="parseInt(scope.row.status) === 1 || parseInt(scope.row.status) === 3">
                <el-button @click="delete_confirm(scope.row)" type="text" class="delete-button">删除</el-button>
              </template>
            </template>
          </el-table-column>
        </el-table>
        <div class="table-pagination" v-show="total_number > 10">
          <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
            :current-page="listParam.page" :page-sizes="[10, 20, 30, 40, 50, 100]" :page-size="listParam.size"
            layout="total, sizes, prev, pager, next, jumper" :total="total_number">
          </el-pagination>
          <div class="pagination-button">
            <el-button @click="getList" type="primary" icon="el-icon-refresh" circle title="刷新数据" size="mini">
            </el-button>
          </div>
        </div>
      </div>
    </div>

    <transition name="el-fade-in-linear">
      <div class="masking" :class="{ activeLive: isActive }">
        <div class="maskingBox" v-loading="viewLoading.status" :element-loading-text="viewLoading.txt">
          <div class="masking_h">
            <span>视频预览</span>
            <i class="el-icon-close" @click="viewClose"></i>
          </div>
          <div class="masking_c">
            <!-- <nativeVideo v-if="showVideoPlayer" :playParam.sync="playParam">
						</nativeVideo> -->
            <dplayerA v-if="showVideoPlayer" :playParam.sync="playParam"></dplayerA>
          </div>
        </div>
      </div>
    </transition>

    <transition name="el-fade-in-linear" lock-scroll="false">
      <div class="masking" :class="{ activeLive: isPDFActive }">
        <div class="maskingBox">
          <div class="masking_h">
            <span>文档预览</span>
            <i class="el-icon-close" @click="viewPDFClose"></i>
          </div>
          <div class="masking-document">
            <div class="pdf-View">
              <iframe :src="viwPdfParam.src" frameborder="0" style="width: 100%; height: 100%;"></iframe>
            </div>
          </div>
        </div>
      </div>
    </transition>
    <!--  -->

    <image-viewer v-if="imagePreview.showViewer" :initial-index="imageIndex" :on-close="closeViewer"
      :url-list="imagePreview.previewSrcList">
    </image-viewer>

    <el-dialog title="音频预览" :visible.sync="voiceVisible" width="800px" top="5vh" @close="handleClose"
      custom-class="imgVisible" :close-on-click-modal="false">
      <!-- :before-close="closeAudio" -->
      <div class="imgViewx">
        <audioPlayer v-if="audioContent.url" :audio-content="audioContent" :on-close="cancelAudio" ref="audioContent" />
      </div>
    </el-dialog>




    <!-- 推下级begin -->
    <el-dialog title="推下级" v-if="pushLowFlag" :visible.sync="pushLowFlag" width="600px" :close-on-click-modal="false">
      <push-low-win @listenPushLow="getPushLowList"></push-low-win>
      <span slot="footer" class="dialog-footer">
        <el-button @click="pushActive()">取 消</el-button>
        <el-button type="primary" @click="pushActive(1)">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 推下级end -->
  </div>
</template>
<script>
import audioPlayer from '../../public/audio-player-copy'
// import nativeVideo from '../../public/nativeVideo'
import dplayerA from "@/components/public/dplayerA.vue";
// import pushLowWin from '@/components/common/push-low-win'
export default {
  data() {
    return {
      allList: [], // 数据处理最终结果
      valueData: [], // 学段/年级/科目id
      optionProps: {
        value: "grade_id",
        label: "name",
      },
      app_code: sessionStorage.getItem('CheckSchoolAppCode'),
      isTopEducation: sessionStorage.getItem('CheckSchoolAppCode') === '00000000000000000000000000000000',
      resoureKindData: [],
      ids: [],/*存放被选中的资源列表 */
      imagePreview: {
        showViewer: false,
        previewSrcList: []
      },
      loading: {
        status: false,
        txt: '获取数据...',
      },
      listData: [],
      listParam: {
        status: 1,
        cate_id: null,
        platform_id: null,
        study_section_id: null,
        grade_id: null,
        subject_id: null,
        version_id: null,
        keyword: '',
        page: 1,
        size: 10,
        data_type: 2,
        authonity: -1,
      },
      cate_id: '',
      status: 1,
      orgLevel2Param: { //获取学段参数
        level: 2,
        pid: null,
        direction: 'balance',
      },
      orgLevel3Param: { //获取年纪参数
        level: 3,
        pid: null,
        direction: 'balance',
      },
      orgLevel2: [{ id: null, name: '全部学段' }],
      orgLevel3: [{ id: null, name: '全部年级' }],
      orgSubject: [{ id: null, name: '全部科目' }],
      orgVersion: [{ id: null, name: '全部版本' }],
      subjectParam: { //获取科目,版本，参数
        type: 2,
        org_id: null,
        status: 1,
      },
      versionParam: { //获取科目,版本，参数
        type: 2,
        org_id: null,
        sub_id: null,
        status: 1
      },
      total_number: 0,
      typeOption: [
        {
          value: 0,
          label: '全部状态'
        },
        {
          value: 2,
          label: '未审核'
        },
        {
          value: 3,
          label: '未通过'
        },
        {
          value: 1,
          label: '已通过'
        },
      ],
      statusArr: {
        2: '未审核',
        3: '未通过',
        1: '已通过'
      },
      classTypeArr: {
        1: '课件', 2: '视频', 3: '教案', 4: '试卷', 5: '其他', 0: '未知'
      },
      watchUpload: {
        picture: false,
        relate_res: false,
      },

      isActive: true,
      isPDFActive: true,
      viwPdfParam: {
        src: '',
        loadedRatio: 0,
        page: 1,
        numPages: 0,
        rotate: 0,
      },
      imgVisible: false,
      imgViewUrl: '',
      voiceVisible: false,
      audioContent: {
        url: '',
        title: ''
      },
      viewLoading: {
        status: false,
        txt: '加载数据...'
      },
      showVideoPlayer: false,
      playParam: { play_url: '' },
      platform_id: null,
      platformList: [],/*学校/教育局列表 */
      schoolcodeData: [], /**存放学校教育局列表 */
      platform: '',/*可推送上级 */
      pid: '',/*可推送上级id */
      pushLowFlag: false,/*推下级弹窗 */
      pushLowObj: null,/*推下级对象 */
      pushLowNames: ['1', '2'],/*获取下级列表参数 */
      schoolList: [],/*学校列表 */
      selSchoolList: [],/*选择的下级列表 */
      ids: [],/*存放被选中的资源列表 */
      pushLowStatus: null,/*记录是否批量推下级*/
      pushUpStatus: null,/*记录是否批量推上级 */
    }
  },
  created() {
    this.getOrgnk();
    this.getOrgLevel2();
    this.getOrgLevel3();
    this.getSubject();
    this.getVersion();
    this.getList();
    this.getSourceKind();
    this.get_schoolcode();
    if (this.$store.state.checkLevel) {
      this.platform_parent();
    }
  },
  watch: {
    'listParam.study_section_id': {
      handler(newVal, oldVal) {
        this.listParam.grade_id = null;
        this.listParam.subject_id = null;
        this.listParam.version_id = null;

        this.orgLevel3Param.pid = newVal;
        this.getOrgLevel3();

        this.subjectParam.org_id = newVal;
        this.getSubject();

        this.versionParam.org_id = newVal;
        this.getVersion();
      }
    },
    'listParam.grade_id': {
      handler(newVal, oldVal) {
        this.listParam.subject_id = null;
        this.listParam.version_id = null;

        this.subjectParam.org_id = newVal;
        this.getSubject();

        this.versionParam.org_id = newVal;
        this.getVersion();
      }
    },
    'listParam.subject_id': {
      handler(newVal, oldVal) {
        this.listParam.version_id = null;

        this.versionParam.sub_id = newVal;
        this.getVersion();
      }
    }
  },
  computed: {
    cancelAudio() {

    },
    /**
     * 获取资源名称
     * @param {Object} obj 记录信息
     */
    getResouseType() {
      return (obj) => {
        let name1 = obj.uo_grade_name ? obj.uo_grade_name : '';
        let name2 = obj.cs_name ? obj.cs_name : '';
        let name3 = obj.cv_name ? obj.cv_name : '';

        let temp = '';

        if (name1) {
          temp = name1 + (name2 ? ' - ' + name2 : '');

          if (name2) {
            temp = name1 + ' - ' + name2 + (name3 ? ' (' + name3 + ')' : '');
          } else {
            temp = name1 + (name3 ? ' (' + name3 + ')' : '');
          }
        } else {
          temp = name2 + (name3 ? ' (' + name3 + ')' : '');
        }

        return temp;
      }
    },
    imageIndex() {
      return this.imagePreview.previewSrcList.indexOf(this.imgViewUrl);
    }
  },
  methods: {
    getOrgnk() {
      let params = {
        app_code: this.app_code
      }
      let success = (res) => {
        this.allList = res.data.children
      };
      this.$ajax.get('api/network/get_org_subject', { params, func: { success } })
    },
    /**获取资源类别 */
    getSourceKind() {
      let success = res => {
        this.resoureKindData = res.data
        this.resoureKindData.unshift({ id: 0, name: '全部' })
      }
      this.$ajax.get('api/resource/resource_cate', { func: { success } })
    },
    handleSelectionChange(val) { /**选框状态 */
      this.ids = [];
      if (val.length > 0) {
        val.forEach(item => {
          this.ids.push(item.id);
        })
      }
    },
    get_schoolcode() { /*获取学校教育局 */
      let params = {
        app_code: this.app_code
      }
      let success = res => {
        this.schoolcodeData = res.data
      }
      this.$ajax.get('api/group/get_platform_org', { params, func: { success } })
    },


    /**
     * 关闭音频播放
     */
    // closeAudio() {
    // 		this.voiceVisible = false;
    // 		document.getElementById("voicepoauy").pause();
    // },
    searchFunc() {
      if (!this.$store.state.platformInformation && this.$store.state.checkLevel) {
        this.listParam.school_code = this.app_code
        this.listParam.grade_id = this.valueData[0]
        this.listParam.subject_id = this.valueData[1]
      }
      this.listParam.cate_id = this.cate_id
      this.listParam.status = this.status;
      this.listParam.page = 1;
      this.getList();
    },
    reset() {
      this.valueData = []
      this.cate_id = ''
      this.status = 1;
      this.orgLevel2Param = { //获取学段参数
        level: 2,
        pid: null,
        direction: 'balance',
      }
      this.orgLevel3Param = { //获取年纪参数
        level: 3,
        pid: null,
        direction: 'balance',
      }
      this.subjectParam = { //获取科目,版本，参数
        type: 2,
        org_id: null,
        status: 1,
      }
      this.versionParam = { //获取科目,版本，参数
        type: 2,
        org_id: null,
        sub_id: null,
        status: 1
      }
      this.listParam = {
        school_code: '',
        platform_id: null,
        study_section_id: null,
        grade_id: null,
        subject_id: null,
        version_id: null,
        keyword: '',
        cate_id: '',
        status: 1,
        page: 1,
        size: 10,
        data_type: 2,
        authonity: -1,
      }
      this.getList();
    },
    jumpEdit(id) {
      this.$router.push('/resources/resource/resource-edit/' + id);
    },
    upload() {
      let success = (res => {
        if (res.data[17] === 0) {
          this.$router.push('/resources/resource/resource-upload');
        } else {
          this.$message.error('系统存储容量小于5G，请清理存储空间（视频/资源文件）或升级存储');
        }
      })

      this.$ajax.get('api/system/system_info', { func: { success: success } })
    },
    // 序号
    typeIndex(index) {
      return index + (this.listParam.page - 1) * this.listParam.size + 1;
    },
    getStatus(val) {
      return this.statusArr[parseInt(val)]
    },
    getClassType(val) {
      return this.classTypeArr[parseInt(val)]
    },
    getList() {

      if (this.$store.state.checkLevel) {
        this.listParam.have_lase = 1
      }
      this.loading.status = true;
      let success = (data => {
        this.loading.status = false;
        this.listData = data.data.data;
        this.total_number = data.data.data_sum;
      })
      let fail = (data => {
        this.loading.status = false;
        this.$message.error(data.msg)
      })
      //执行请求，并将回调方法变成config成员以便鉴权过期可以执行
      this.$ajax.get('api/resource/resource', { params: this.listParam, func: { success: success, fail: fail } })
    },
    //获取学段
    getOrgLevel2() {
      let success = (data => {
        this.orgLevel2 = data.data;
        this.orgLevel2.unshift({ id: null, name: '全部学段' })
      })
      this.$ajax.get('api/org/org', { params: this.orgLevel2Param, func: { success: success } })
    },
    //获取年级
    getOrgLevel3() {
      let success = (data => {
        this.orgLevel3 = data.data;
        this.orgLevel3.unshift({ id: null, name: '全部年级' })
      })
      this.$ajax.get('api/org/org', { params: this.orgLevel3Param, func: { success: success } })
    },
    //获取科目
    getSubject() {
      let success = (data => {
        this.orgSubject = data.data;
        this.orgSubject.unshift({ id: null, name: '全部科目' });
      })
      this.$ajax.get('api/cate/subject', { params: this.subjectParam, func: { success: success } })
    },
    //获取版本
    getVersion() {
      let success = (data => {
        this.orgVersion = data.data;
        this.orgVersion.unshift({ id: null, name: '全部版本' });
      })
      this.$ajax.get('api/cate/version', { params: this.versionParam, func: { success: success } })
    },
    delete_confirm(obj) {
      let yes = (data => {
        this.delete(obj.id, 0);
      })
      let cancel = (data => { })
      this.e_confirm({ yes: yes, cancel: cancel, txt: '确定将 ' + obj.name + ' 删除吗？' });

    },
    delete(id, status) {
      let success = (data => {
        this.$message.success(data.msg);

        if (this.listData.length - 1 === 0) {
          if (this.listParam.page > 1) {
            this.listParam.page--;
          } else {
            this.listParam.page = 1;
          }
        }

        this.getList();
      });
      this.$ajax.delete('api/resource/resource', { params: { id: id, status: status }, func: { success: success } })
    },
    delAllresource() { // 批量删除资源
      if (this.ids.length <= 0) {
        this.$message.warning('请选择要删除的选项');
        return false;
      }
      const cancel = (res => { })
      const yes = (res => {
        this.listData.forEach((item, index) => {
          this.ids.forEach((itm, idx) => {
            if (item.id == itm) {
              this.delete(itm, 0)
            }
          })
        })
      })
      this.e_confirm({ yes, cancel, txt: "确定要删除选中的资源吗？" });
    },
    approve_confirm(obj) {
      let yes = (data => {
        var params = {
          id: obj.id,
          status: 1,
          comment: ''
        }
        this.approve(params);
      })
      let cancel = (data => { })
      this.e_confirm({ yes: yes, cancel: cancel, txt: '确定批准 ' + obj.name + '吗？' });

    },
    disapprove_dialog(obj) {
      this.$prompt('请输入拒绝理由', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputPattern: /^[\S]{1,30}$/,
        inputErrorMessage: '拒绝理由不能为空，且不能超过30个字符'
      }).then(({ value }) => {
        var params = {
          id: obj.id,
          status: 3,
          comment: value
        }
        this.approve(params);
      }).catch(() => {

      });
    },
    approve(params) {
      let success = (data => {
        this.$message.success(data.msg)
        this.getList();
      });
      this.$ajax.post('api/resource/approve', params, { func: { success: success } })
    },
    handleSizeChange(val) {
      this.listParam.page = 1;
      this.listParam.size = val;
      this.getList()
    },
    handleCurrentChange(val) {
      this.listParam.page = val;
      this.getList();
    },
    pdfPageChange(val) {
      this.viwPdfParam.page = val;
    },
    error: function(err) {
      //this.$message.error('读取文件失败');
    },

    //资源预览转发
    viewResource(obj) {

      this.viewLoading.status = true;

      //视频预览
      if (parseInt(obj.file_type) === 6) {
        this.isActive = false
      }
      //图片预览
      else if (parseInt(obj.file_type) === 3) {
        this.imgVisible = true;
      }
      //文档预览
      else if (parseInt(obj.file_type) === 1) {
        // this.isPDFActive = false
      }
      //音频预览
      else if (parseInt(obj.file_type) === 5) {
        this.voiceVisible = true;
        this.voiceView(obj)
      } else {
        this.$message.warning("不支持预览的资源类型")
        return false;
      }
      let success = (data => {
        var result = data.data;
        //视频预览
        if (parseInt(result.file_type) === 6) {
          this.videoView(result.path);
        }
        //图片预览
        else if (parseInt(result.file_type) === 3) {
          this.imgView(result.path);
        }
        //文档预览
        else if (parseInt(result.file_type) === 1) {
          this.isPDFActive = false
          this.pdfView(result.path);
        }
        //音频预览
        else if (parseInt(result.file_type) === 5) {
          // this.voiceView(result)
        } else {
          this.$message.warning("不支持预览的资源类型")
        }
      })
      let fail = (data => {
        this.isPDFActive = true
        this.viewLoading.status = false;
        this.$message.error(data.msg)
      })
      this.$ajax.get('api/resource/view_info', { params: { id: obj.id, is_video: obj.is_video }, func: { success: success, fail: fail } })

    },
    handleClose() {
      this.audioContent.url = ''
      this.audioContent.title = ''
    },
    voiceView(obj) {
      this.audioContent.url = this.BASE_URL + obj.path;
      this.audioContent.title = obj.name;
      // document.getElementById("voicepoauy").load();
    },
    imgView(url) {
      this.imgViewUrl = url;
      this.imagePreview.showViewer = true;
      this.imagePreview.previewSrcList = [url];
    },
    closeViewer() {
      this.imagePreview.showViewer = false;
    },
    //pdf预览
    pdfView(url) {
      this.viwPdfParam.src = (url)
      // this.viwPdfParam.src =  pdf.createLoadingTask(url)
    },
    viewPDFClose() {
      this.isPDFActive = true
    },
    //关闭视频预览
    viewClose() {
      this.showVideoPlayer = false;
      this.isActive = true

    },
    //视频预览
    videoView(url) {
      this.showVideoPlayer = true;
      this.playParam.play_url = url;
    },
    down(obj) {
      var form = document.createElement("form");
      var type = 1;
      form.action = this.BASE_URL + '/index/resource/resourcedownload';
      form.method = 'post';
      form.style.display = "none";

      var opt_id = document.createElement("textarea");
      opt_id.name = 'id';
      opt_id.value = obj.id;
      form.appendChild(opt_id);
      var opt_type = document.createElement("textarea");
      opt_type.name = 'type';
      opt_type.value = type;
      form.appendChild(opt_type);
      document.body.appendChild(form);
      form.submit();
      document.body.removeChild(form);
    },
    get_canseeposition() {/*获取学校/教育局列表 */
      const success = res => {
        this.platformList = res.data.data;
      }
      this.$ajax.get('api/level/get_canseeposition_school', { params: {}, func: { success: success } })
    },
    pushLow(data) {/*推下级 */
      this.pushLowObj = data;
      this.pushLowStatus = null;
      this.pushLowFlag = true;
    },
    pushActive(flag) {/*推下级执行 */
      if (flag) {
        if (this.selSchoolList.length <= 0) {
          this.$message.error('请选择要推送的下级');
          return;
        }
        let params = {
          id: [],
          res_type: 'resource',
          school_id: '',
          push_type: 2,
        }
        if (this.pushLowStatus) {
          params.id = this.ids;
        } else {
          params.id.push(this.pushLowObj.id);
        }
        let arr = [];
        this.selSchoolList.forEach(item => {
          arr.push(item.id);
        })
        params.school_id = arr.join();
        const success = res => {
          this.pushLowHide();
          this.ids = [];
          this.getList();
        }
        this.$ajax.post("api/level/push_data", params, {
          func: { success: success }
        });
      } else {
        this.pushLowHide();
      }
    },
    pushLowAll() {/*批量推下级 */
      if (this.ids.length <= 0) {
        this.$message.error('请选择要推送的选项');
        return
      }
      this.pushLowStatus = 1;
      this.pushLowFlag = true;
    },
    getPushLowList(list) {/*获取组件传递列表 */
      this.selSchoolList = list;
    },
    pushLowHide() {/*推下级窗口隐藏 */
      this.pushLowObj = null;
      this.pushLowFlag = false;
    },
    platform_parent() {/*获取可推送上级 */
      const success = res => {
        if (!is_empty(res.data)) {
          this.platform = res.data;
          this.pid = res.data.id;
        }
      }
      this.$ajax.get('api/level/platform_parent', { params: {}, func: { success: success } })
    },
    pushUp(id) {
      let params = {
        resource_id: id,
      }
      const success = res => {
        this.$message.success(res.msg)
        this.ids = [];
        this.getList();
      }
      this.$ajax.post("api/resource/resource_push", params, { func: { success: success } });
    },
    pushUpTrigger(data) {
      let title = `是否要将资源推送至${this.platform.name ? this.platform.name : '上级教育局'}？（需经过审核）`;
      this.$confirm(title, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.pushUp(data.id);
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消推送'
        });
      });
    },
    pushUpAll() {/*批量推上级 */
      if (this.ids.length <= 0) {
        this.$message.error('请选择要推送的选项');
        return
      }
      const cancel = (res => { })
      const yes = (res => {
        this.listData.forEach((item, index) => {
          this.ids.forEach((itm, idx) => {
            if (item.id == itm) {
              this.pushUp(itm)
            }
          })
        })
      })
      this.e_confirm({ yes, cancel, txt: "是否要推送选中的资源？" });
    },
    toLink(link) {
      this.$router.push(link);
    },
  },
  components: {
    // pdf,
    // nativeVideo,
    dplayerA,
    // pushLowWin,
    audioPlayer
  }
}
</script>
<style lang="scss">
.zh-teaching-resources {
  .el-table__body-wrapper table tbody {
    td:nth-child(8) {
      padding: 0;
    }
  }

  .masking {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    // height: 100%;
    transition: .5s;
    background: rgba(0, 0, 0, .3);
    z-index: 4;



    .masking_h {
      padding: 10px 15px;
      background: #348EFC;
      text-align: center;
      text-align-last: justify;

      >span,
      >i {
        font-size: 16px;
        text-align-last: initial;
        display: inline-block;
        vertical-align: middle;
        color: #fff;
      }

      >i {
        cursor: pointer;
      }
    }

  }

  // .masking_c {
  // 	height: 450px;

  // 	.el-pagination {
  // 		padding-bottom: 20px;
  // 	}
  // }

  .masking_c {
    height: 450px;
    padding: 15px;
  }

  .activeLive {
    opacity: 0;
    visibility: hidden;
  }

  .imgVisible {
    display: inline-block;
    vertical-align: middle;
    background: none;
    text-align: left;
    // min-width: 550px;
    // min-height: 550px;
    background: rgba(109, 116, 125, 0.78);
    margin: 0;

    .el-dialog__header {
      // display: none;
    }

    .el-dialog__body {
      text-align: center;
      padding: 0;

      img {
        max-width: 100%;
      }
    }
  }

  .el-dialog__wrapper {
    text-align: center;
  }
}
</style>
<style lang="scss" scoped>
	.masking{
		display: block;
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		transition: .5s;
		background: rgba(0,0,0,.3);
		z-index: 4;
		.maskingBox{
			position: absolute;
			top: 20%;
			left: 50%;
			width: 800px;
			margin-left: -400px;
			background: #fff;
		}
  }
</style>
